<template>
    <div class='y-test2'>
        <VBtn @click="down">调用meta钱包api</VBtn>
    </div>
</template>
<script lang='ts' setup>
import { onMounted } from 'vue';
import { MetaMaskSDK } from '@metamask/sdk';
import detectProvider from '@metamask/detect-provider';
const dappMetadata = {
    name: "Example JavaScript Dapp",
    url: window.location.host,
    dappMetadata: {

    }
}
async function down() {
    const provider: any = await detectProvider();
    console.log(provider,"providerprovider");
    
    if (provider) {
        // 连接到MetaMask提供者
      let temp = await provider.request({ method: 'eth_requestAccounts' });
        // 用户已授权，可以进行交互
        console.log('yzt// 用户已授权，可以进行交互',temp);
    } else {
        // MetaMask未安装或未授权
        // 提示用户安装MetaMask插件或授权访问
        console.log('yzt// 提示用户安装MetaMask插件或授权访问');
    }
}
</script>
<style lang='less' scoped>
.y-test2 {
    background-color: rebeccapurple;
    height: 20vh;
    z-index: 100;
    position: fixed;
    left: 20px;
    top: 20px;
}
</style>